/*
 * HttpTokenAuth.h
 *
 *  Created on: 2018年2月9日
 *      Author: terry
 */

#ifndef HTTPTOKENAUTH_H_
#define HTTPTOKENAUTH_H_

#include "BasicType.h"
#include <string>


class HttpUser
{
public:
	std::string username;
	std::string	password;
	std::string	sha;

	HttpUser()
	{
	}

	HttpUser(const std::string& u, const std::string& p):
		username(u),
		password(p)
	{
	}
};

class HttpUserStore
{
public:
	virtual ~HttpUserStore() {}

	virtual bool findUser(const std::string& username, HttpUser& user) =0;
};


class HttpTokenAuth
{
public:
	static const size_t EXPIRATION = 60 * 10;

public:
	virtual ~HttpTokenAuth() {}

	virtual void setExpiration(size_t seconds) =0;

	virtual bool login(const std::string& username, const std::string& password, std::string& token) =0;

	virtual void logout(const std::string& token) =0;

	virtual bool check(const std::string& token, std::string& username) =0;

	virtual void clear() =0;

	virtual size_t size() =0;

	virtual bool getAt(size_t idx, std::string& username, std::string& token) =0;

};

#endif /* HTTPTOKENAUTH_H_ */
